package com.example.demo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class J8list {
    public static void main(String[] args) {
        List<String> words = new ArrayList<String>();
        words.add("hello");
        words.add("word");
        List<String> words1 = new ArrayList<String>();
        words1.add("1");
        words1.add("word");

        /**
         * map 接受的是对当前对象的处理
         */
        List<String[]> ss = words.stream().map(x -> x.split("")).distinct().collect(Collectors.toList());


        /**
         * Arrays.Stream
         */
        List<String> ff = words.stream().flatMap(x -> Arrays.stream(x.split(""))).distinct().collect(Collectors.toList());
        for (String s : ff) {
            System.out.println(s);

        }
        /**
         * flatMap 接受的是stream
         */
        List<String> list = Stream.of(words, words1).flatMap(x -> x.stream()).distinct().collect(Collectors.toList());
        for (String s : list) {
            System.out.println(s);

        }
    }
}
